<?php
/**
 * Anniversary.php
 * 文件描述 纪念日控制器
 * Created on 2020/8/31 11:46
 * Created by 刘小龙 595929049@qq.com
 */

namespace app\xiangji\controller;


use app\Request;
use app\xiangji\BaseController;
use app\xiangji\exception\BadRequestException;
use app\xiangji\services\LoveAchieveService;
use think\App;

class LoveAchieve extends BaseController
{
    private $achieveService;

    public function __construct(LoveAchieveService $achieveService)
    {
        $this->achieveService = $achieveService;
    }

    public function queryAchieve(Request $request)
    {
        $type = $request->get('type');
        if (!$type || !in_array($type, [1, 2, 3])){
            throw new BadRequestException('成就类型错误');
        }
        $result = $this->achieveService->queryAchieve((int)$type);
        return $this->success($result);
    }

    public function acceptAchieveReward($id)
    {
        $result = $this->achieveService->acceptAchieveReward($id);
        return $this->success($result);
    }
}
